package com.group.login;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.catalina.Session;

import com.group.controller.CommandHandler;
import com.group.member.MemberDAO;

public class LoginHandler implements CommandHandler{

	@Override
	public String process(HttpServletRequest request,
			HttpServletResponse response) throws Throwable {

		HttpSession session = request.getSession();
	
		String id = request.getParameter("id");
		String passwd = request.getParameter("passwd");
		
		//	1. 명령어와 관련된 비지니스 로직 처리
		MemberDAO memberDao = new MemberDAO();
		boolean result = memberDao.loginChk(id,passwd);
		
		//	2. 뷰 페이지에서 사용할 정보 저장
		if(result==true){
			session.setAttribute("idKey", id);
			//	3. 뷰 페이지의 URI 리턴
//			return "/board/board_list.jsp";
			return "/groupware/board/boardlist.jsp";
		}else{
			return "/groupware/login/login.html";
		}
		
	}

}
